package com.thinkcube.edutainment.adapters;

import java.util.List;

import org.androidannotations.annotations.EBean;
import org.androidannotations.annotations.RootContext;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.thinkcube.edutainment.domain.data.PackageData;
import com.thinkcube.edutainment.service.viewitem.MyPackageItem;
import com.thinkcube.edutainment.service.viewitem.MyPackageItem_;



@EBean
public class MyPackageAdapter extends BaseAdapter {

	List<PackageData> packageDataList;

	@RootContext
	Context context;

	@Override
	public View getView(final int position, final View convertView,
			final ViewGroup parent) {

		MyPackageItem myPackageItem;
		if (convertView == null) {
			myPackageItem = MyPackageItem_.build(context);
		} else {
			myPackageItem = (MyPackageItem) convertView;
		}

		myPackageItem.bind(getItem(position));

		return myPackageItem;
	}

	

	public List<PackageData> getPackageDataList() {
		return packageDataList;
	}



	public void setPackageDataList(List<PackageData> packageDataList) {
		this.packageDataList = packageDataList;
	}



	@Override
	public int getCount() {
		return packageDataList.size();
	}

	@Override
	public PackageData getItem(final int position) {
		return packageDataList.get(position);
	}

	@Override
	public long getItemId(final int position) {
		return position;
	}

}
